<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!-- <el-form-item label="编号" prop="a2">
        <el-input
          v-model="queryParams.a2"
          placeholder="请输入编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="日期" prop="a51">
        <el-date-picker
          :editable="false"
          clearable
          size="small"
          v-model="queryParams.a51"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="总有功表表数" prop="a3">
        <el-input
          v-model="queryParams.a3"
          placeholder="请输入总有功表表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总有功表实用量" prop="a4">
        <el-input
          v-model="queryParams.a4"
          placeholder="请输入总有功表实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总无功表表数" prop="a5">
        <el-input
          v-model="queryParams.a5"
          placeholder="请输入总无功表表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="总无功表实用量" prop="a6">
        <el-input
          v-model="queryParams.a6"
          placeholder="请输入总无功表实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="吹灌旋一体机表数" prop="a7">
        <el-input
          v-model="queryParams.a7"
          placeholder="请输入吹灌旋一体机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="吹灌旋一体机实用量" prop="a8">
        <el-input
          v-model="queryParams.a8"
          placeholder="请输入吹灌旋一体机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="贴标机表数" prop="a9">
        <el-input
          v-model="queryParams.a9"
          placeholder="请输入贴标机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="贴标机实用量" prop="a10">
        <el-input
          v-model="queryParams.a10"
          placeholder="请输入贴标机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="纸包机表数" prop="a11">
        <el-input
          v-model="queryParams.a11"
          placeholder="请输入纸包机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="纸包机实用量" prop="a12">
        <el-input
          v-model="queryParams.a12"
          placeholder="请输入纸包机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="膜包机表数" prop="a13">
        <el-input
          v-model="queryParams.a13"
          placeholder="请输入膜包机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="膜包机实用量" prop="a14">
        <el-input
          v-model="queryParams.a14"
          placeholder="请输入膜包机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="码垛机表数" prop="a15">
        <el-input
          v-model="queryParams.a15"
          placeholder="请输入码垛机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="码垛机实用量" prop="a16">
        <el-input
          v-model="queryParams.a16"
          placeholder="请输入码垛机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="低压空压机表数" prop="a17">
        <el-input
          v-model="queryParams.a17"
          placeholder="请输入低压空压机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="低压空压机实用量" prop="a18">
        <el-input
          v-model="queryParams.a18"
          placeholder="请输入低压空压机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高压空压机表数" prop="a19">
        <el-input
          v-model="queryParams.a19"
          placeholder="请输入高压空压机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高压空压机实用量" prop="a20">
        <el-input
          v-model="queryParams.a20"
          placeholder="请输入高压空压机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提升机表数" prop="a21">
        <el-input
          v-model="queryParams.a21"
          placeholder="请输入提升机表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提升机实用量" prop="a22">
        <el-input
          v-model="queryParams.a22"
          placeholder="请输入提升机实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="瓶输送系统表数" prop="a23">
        <el-input
          v-model="queryParams.a23"
          placeholder="请输入瓶输送系统表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="瓶输送系统实用量" prop="a24">
        <el-input
          v-model="queryParams.a24"
          placeholder="请输入瓶输送系统实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="净化系统表数" prop="a25">
        <el-input
          v-model="queryParams.a25"
          placeholder="请输入净化系统表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="净化系统实用量" prop="a26">
        <el-input
          v-model="queryParams.a26"
          placeholder="请输入净化系统实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="水处理表数" prop="a27">
        <el-input
          v-model="queryParams.a27"
          placeholder="请输入水处理表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="水处理实用量" prop="a28">
        <el-input
          v-model="queryParams.a28"
          placeholder="请输入水处理实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库表数" prop="a29">
        <el-input
          v-model="queryParams.a29"
          placeholder="请输入仓库表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库实用量" prop="a30">
        <el-input
          v-model="queryParams.a30"
          placeholder="请输入仓库实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货梯表数" prop="a31">
        <el-input
          v-model="queryParams.a31"
          placeholder="请输入货梯表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="货梯实用量" prop="a32">
        <el-input
          v-model="queryParams.a32"
          placeholder="请输入货梯实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="源水间表数" prop="a33">
        <el-input
          v-model="queryParams.a33"
          placeholder="请输入源水间表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="源水间实用量" prop="a34">
        <el-input
          v-model="queryParams.a34"
          placeholder="请输入源水间实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实用量合计" prop="a39">
        <el-input
          v-model="queryParams.a39"
          placeholder="请输入实用量合计"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生活水、传达室表数" prop="a35">
        <el-input
          v-model="queryParams.a35"
          placeholder="请输入生活水、传达室表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生活水、传达室实用量" prop="a36">
        <el-input
          v-model="queryParams.a36"
          placeholder="请输入生活水、传达室实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="宿舍区用电表数" prop="a37">
        <el-input
          v-model="queryParams.a37"
          placeholder="请输入宿舍区用电表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="宿舍区用电实用量" prop="a38">
        <el-input
          v-model="queryParams.a38"
          placeholder="请输入宿舍区用电实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="宿舍空调表数" prop="a40">
        <el-input
          v-model="queryParams.a40"
          placeholder="请输入宿舍空调表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="宿舍空调实用量" prop="a41">
        <el-input
          v-model="queryParams.a41"
          placeholder="请输入宿舍空调实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="配电室表数" prop="a42">
        <el-input
          v-model="queryParams.a42"
          placeholder="请输入配电室表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="配电室实用量" prop="a43">
        <el-input
          v-model="queryParams.a43"
          placeholder="请输入配电室实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实用量合计：" prop="a44">
        <el-input
          v-model="queryParams.a44"
          placeholder="请输入实用量合计："
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="源水间和生活水表数" prop="a45">
        <el-input
          v-model="queryParams.a45"
          placeholder="请输入源水间和生活水表数"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="源水间和生活水实用量" prop="a46">
        <el-input
          v-model="queryParams.a46"
          placeholder="请输入源水间和生活水实用量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="变压器温度A相" prop="a47">
        <el-input
          v-model="queryParams.a47"
          placeholder="请输入变压器温度A相"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="变压器温度B相" prop="a48">
        <el-input
          v-model="queryParams.a48"
          placeholder="请输入变压器温度B相"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="变压器温度C相" prop="a49">
        <el-input
          v-model="queryParams.a49"
          placeholder="请输入变压器温度C相"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="记录人" prop="a50">
        <UserDialog
          @dialogChange="queryParams.a50 = $event.label"
          :echoValue="queryParams.a50"
          :multiple="false"
          placeholder="请选择人员"
        />
        <!-- <el-input
          v-model="queryParams.a50"
          placeholder="请输入记录人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
        <!-- <el-select
          v-model="queryParams.a50"
          filterable
          allow-create
          placeholder="请选择操作人"
          style="width: 100%"
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="item in userList"
            :key="item.nickName"
            :label="item.nickName"
            :value="item.nickName"
          ></el-option>
        </el-select>-->
      </el-form-item>

      <!-- <el-form-item label="基地" prop="a52">
        <el-input
          v-model="queryParams.a52"
          placeholder="请输入基地"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['productionmetermonth:productionmetermonth:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['productionmetermonth:productionmetermonth:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['productionmetermonth:productionmetermonth:remove']"
          >删除</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['productionmetermonth:productionmetermonth:export']"
          >导出</el-button
        >
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="productionmetermonthList"
      @selection-change="handleSelectionChange"
      max-height="500"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="100px" />
      <el-table-column label="开始日期" align="center" prop="a51" width="180" />
      <el-table-column
        label="结束日期"
        align="center"
        prop="a511"
        width="180"
      />
      <el-table-column label="报表编码" align="center" prop="a2" />
      <!-- <el-table-column label="总有功表表数" align="center" prop="a3" />
      <el-table-column label="总有功表实用量" align="center" prop="a4" />
      <el-table-column label="总无功表表数" align="center" prop="a5" />
      <el-table-column label="总无功表实用量" align="center" prop="a6" />
      <el-table-column label="吹灌旋一体机表数" align="center" prop="a7" />
      <el-table-column label="吹灌旋一体机实用量" align="center" prop="a8" />
      <el-table-column label="贴标机表数" align="center" prop="a9" />
      <el-table-column label="贴标机实用量" align="center" prop="a10" />
      <el-table-column label="纸包机表数" align="center" prop="a11" />
      <el-table-column label="纸包机实用量" align="center" prop="a12" />
      <el-table-column label="膜包机表数" align="center" prop="a13" />
      <el-table-column label="膜包机实用量" align="center" prop="a14" />
      <el-table-column label="码垛机表数" align="center" prop="a15" />
      <el-table-column label="码垛机实用量" align="center" prop="a16" />
      <el-table-column label="低压空压机表数" align="center" prop="a17" />
      <el-table-column label="低压空压机实用量" align="center" prop="a18" />
      <el-table-column label="高压空压机表数" align="center" prop="a19" />
      <el-table-column label="高压空压机实用量" align="center" prop="a20" />
      <el-table-column label="提升机表数" align="center" prop="a21" />
      <el-table-column label="提升机实用量" align="center" prop="a22" />
      <el-table-column label="瓶输送系统表数" align="center" prop="a23" />
      <el-table-column label="瓶输送系统实用量" align="center" prop="a24" />
      <el-table-column label="净化系统表数" align="center" prop="a25" />
      <el-table-column label="净化系统实用量" align="center" prop="a26" />
      <el-table-column label="水处理表数" align="center" prop="a27" />
      <el-table-column label="水处理实用量" align="center" prop="a28" />
      <el-table-column label="仓库表数" align="center" prop="a29" />
      <el-table-column label="仓库实用量" align="center" prop="a30" />
      <el-table-column label="货梯表数" align="center" prop="a31" />
      <el-table-column label="货梯实用量" align="center" prop="a32" />
      <el-table-column label="源水间表数" align="center" prop="a33" />
      <el-table-column label="源水间实用量" align="center" prop="a34" />
      <el-table-column label="实用量合计" align="center" prop="a39" />
      <el-table-column label="生活水、传达室表数" align="center" prop="a35" />
      <el-table-column label="生活水、传达室实用量" align="center" prop="a36" />
      <el-table-column label="宿舍区用电表数" align="center" prop="a37" />
      <el-table-column label="宿舍区用电实用量" align="center" prop="a38" />
      <el-table-column label="宿舍空调表数" align="center" prop="a40" />
      <el-table-column label="宿舍空调实用量" align="center" prop="a41" />
      <el-table-column label="配电室表数" align="center" prop="a42" />
      <el-table-column label="配电室实用量" align="center" prop="a43" />
      <el-table-column label="实用量合计：" align="center" prop="a44" />
      <el-table-column label="源水间和生活水表数" align="center" prop="a45" />
      <el-table-column label="源水间和生活水实用量" align="center" prop="a46" />
      <el-table-column label="变压器温度A相" align="center" prop="a47" />
      <el-table-column label="变压器温度B相" align="center" prop="a48" />
      <el-table-column label="变压器温度C相" align="center" prop="a49" /> -->
      <!--      <el-table-column label="基地" align="center" prop="deptName" />-->
      <el-table-column label="记录人" align="center" prop="a50" />

      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="250px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="excelhandleView(scope.row)"
            >导出</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['productionmetermonth:productionmetermonth:edit']"
          >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            >查看</el-button
          >

          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['productionmetermonth:productionmetermonth:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改生产基地用电记录对话框 -->
    <el-dialog
      fullscreen
      :title="title"
      :visible.sync="open"
      width="700px"
      append-to-body
      custom-class="myDialog"
    >
      <TableHeader
        @nameChange="nameChange"
        :data="{
          mainTitle: '生产基地用电记录',
          company: '青岛崂山矿泉水有限公司',
          code: form.a2,
        }"
      />
      <el-form ref="form" :model="form" :rules="rules" label-width="155px">
        <el-row>
          <!-- <el-col :span="12">
            <el-form-item label="编号" prop="a2">
              <el-input
                v-model="form.a2"
                placeholder="请输入编号"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col> -->
          <el-col :span="8">
            <el-form-item label="开始日期" prop="a51">
              <el-date-picker
                :editable="false"
                clearable
                v-model="form.a51"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="结束日期" prop="a511">
              <el-date-picker
                :editable="false"
                clearable
                v-model="form.a511"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item>
              <el-button
                type="primary"
                plain
                icon="el-icon-search"
                @click="handleDate"
                >获取数据</el-button
              >
            </el-form-item>
          </el-col>
          <br />
          <!-- <el-divider content-position="center">总表记录</el-divider> -->
          <br />
          <el-col :span="12">
            <el-form-item label="总电表表数" prop="a3">
              <el-input
                v-model="form.a3"
                placeholder="请输入总电表表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总电表实用量" prop="a4">
              <el-input
                type="number"
                v-model="form.a4"
                placeholder="请输入总电表实用量"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="总无功表表数" prop="a5">
              <el-input v-model="form.a5" placeholder="请输入总无功表表数" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总无功表实用量" prop="a6">
              <el-input v-model="form.a6" placeholder="请输入总无功表实用量" :disabled="openDisabled" />
            </el-form-item>
          </el-col>-->
          <el-col :span="12">
            <el-form-item label="吹灌旋一体机表数" prop="a7">
              <el-input
                v-model="form.a7"
                placeholder="请输入吹灌旋一体机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="吹灌旋一体机实用量" prop="a8">
              <el-input
                type="number"
                v-model="form.a8"
                placeholder="请输入吹灌旋一体机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="贴标机表数" prop="a9">
              <el-input
                v-model="form.a9"
                placeholder="请输入贴标机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="贴标机实用量" prop="a10">
              <el-input
                type="number"
                v-model="form.a10"
                placeholder="请输入贴标机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="纸包机表数" prop="a11">
              <el-input
                v-model="form.a11"
                placeholder="请输入纸包机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="纸包机实用量" prop="a12">
              <el-input
                type="number"
                v-model="form.a12"
                placeholder="请输入纸包机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="膜包机表数" prop="a13">
              <el-input
                v-model="form.a13"
                placeholder="请输入膜包机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="膜包机实用量" prop="a14">
              <el-input
                type="number"
                v-model="form.a14"
                placeholder="请输入膜包机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="码垛机表数" prop="a15">
              <el-input
                v-model="form.a15"
                placeholder="请输入码垛机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="码垛机实用量" prop="a16">
              <el-input
                type="number"
                v-model="form.a16"
                placeholder="请输入码垛机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="低压空压机表数" prop="a17">
              <el-input
                v-model="form.a17"
                placeholder="请输入低压空压机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="低压空压机实用量" prop="a18">
              <el-input
                type="number"
                v-model="form.a18"
                placeholder="请输入低压空压机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高压空压机表数" prop="a19">
              <el-input
                v-model="form.a19"
                placeholder="请输入高压空压机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="高压空压机实用量" prop="a20">
              <el-input
                type="number"
                v-model="form.a20"
                placeholder="请输入高压空压机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="提升机表数" prop="a21">
              <el-input
                v-model="form.a21"
                placeholder="请输入提升机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提升机实用量" prop="a22">
              <el-input
                v-model="form.a22"
                placeholder="请输入提升机实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="瓶输送系统表数" prop="a23">
              <el-input
                v-model="form.a23"
                placeholder="请输入瓶输送系统表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="瓶输送系统实用量" prop="a24">
              <el-input
                type="number"
                v-model="form.a24"
                placeholder="请输入瓶输送系统实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="净化系统表数" prop="a25">
              <el-input
                v-model="form.a25"
                placeholder="请输入净化系统表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="净化系统实用量" prop="a26">
              <el-input
                v-model="form.a26"
                placeholder="请输入净化系统实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="水处理表数" prop="a27">
              <el-input
                v-model="form.a27"
                placeholder="请输入水处理表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="水处理实用量" prop="a28">
              <el-input
                type="number"
                v-model="form.a28"
                placeholder="请输入水处理实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仓库表数" prop="a29">
              <el-input
                v-model="form.a29"
                placeholder="请输入仓库表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仓库实用量" prop="a30">
              <el-input
                type="number"
                v-model="form.a30"
                placeholder="请输入仓库实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货梯表数" prop="a31">
              <el-input
                v-model="form.a31"
                placeholder="请输入货梯表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="货梯实用量" prop="a32">
              <el-input
                type="number"
                v-model="form.a32"
                placeholder="请输入货梯实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="源水间表数" prop="a33">
              <el-input
                v-model="form.a33"
                placeholder="请输入源水间表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="源水间实用量" prop="a34">
              <el-input
                type="number"
                v-model="form.a34"
                placeholder="请输入源水间实用量"
                :disabled="openDisabled"
                @change="productionTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="实用量合计" prop="a39">
              <el-input
                type="number"
                v-model="form.a39"
                placeholder="请输入实用量合计"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <br />
          <el-divider content-position="center">生活用电记录</el-divider>
          <br />
          <el-col :span="12">
            <el-form-item label="生活水、传达室表数" prop="a35">
              <el-input
                v-model="form.a35"
                placeholder="请输入生活水、传达室表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="生活水、传达室实用量" prop="a36">
              <el-input
                type="number"
                v-model="form.a36"
                placeholder="请输入生活水、传达室实用量"
                :disabled="openDisabled"
                @change="liveTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="宿舍区用电表数" prop="a37">
              <el-input
                v-model="form.a37"
                placeholder="请输入宿舍区用电表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="宿舍区用电实用量" prop="a38">
              <el-input
                type="number"
                v-model="form.a38"
                placeholder="请输入宿舍区用电实用量"
                :disabled="openDisabled"
                @change="liveTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="宿舍空调表数" prop="a40">
              <el-input
                v-model="form.a40"
                placeholder="请输入宿舍空调表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="宿舍空调实用量" prop="a41">
              <el-input
                type="number"
                v-model="form.a41"
                placeholder="请输入宿舍空调实用量"
                :disabled="openDisabled"
                @change="liveTotal"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配电室表数" prop="a42">
              <el-input
                v-model="form.a42"
                placeholder="请输入配电室表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配电室实用量" prop="a43">
              <el-input
                type="number"
                v-model="form.a43"
                placeholder="请输入配电室实用量"
                :disabled="openDisabled"
                @change="liveTotal"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="提升机表数" prop="a21">
              <el-input
                v-model="form.a21"
                placeholder="请输入提升机表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提升机实用量" prop="a22">
              <el-input
                type="number"
                v-model="form.a22"
                placeholder="请输入提升机实用量"
                :disabled="openDisabled"
                @change="liveTotal"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="净化系统表数" prop="a25">
              <el-input
                v-model="form.a25"
                placeholder="请输入净化系统表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="净化系统实用量" prop="a26">
              <el-input
                type="number"
                v-model="form.a26"
                placeholder="请输入净化系统实用量"
                :disabled="openDisabled"
                @change="liveTotal"
              />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="实用量合计：" prop="a44">
              <el-input
                type="number"
                v-model="form.a44"
                placeholder="请输入实用量合计："
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <br />
          <el-divider content-position="center">其他用电记录</el-divider>
          <br />
          <!-- <el-col :span="12">
            <el-form-item label="源水间和生活水表数" prop="a45">
              <el-input
                v-model="form.a45"
                placeholder="请输入源水间和生活水表数"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="源水间和生活水实用量" prop="a46">
              <el-input
                v-model="form.a46"
                placeholder="请输入源水间和生活水实用量"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="变压器温度A相" prop="a47">
              <el-input
                type="number"
                v-model="form.a47"
                placeholder="请输入变压器温度A相"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="变压器温度B相" prop="a48">
              <el-input
                type="number"
                v-model="form.a48"
                placeholder="请输入变压器温度B相"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="变压器温度C相" prop="a49">
              <el-input
                type="number"
                v-model="form.a49"
                placeholder="请输入变压器温度C相"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="记录人" prop="a50">
              <UserDialog
                @dialogChange="form.a50 = $event.label"
                :echoValue="form.a50"
                :multiple="false"
                :openDisabled="openDisabled"
                placeholder="请选择人员"
              />
              <!-- <el-input
                v-model="form.a50"
                placeholder="请输入记录人"
                :disabled="openDisabled"
              /> -->
              <!-- <el-select
                v-model="form.operator"
                filterable
                allow-create
                placeholder="请选择记录人"
                style="width: 100%"
                :disabled="openDisabled"
              >
                <el-option
                  v-for="item in userList"
                  :key="item.nickName"
                  :label="item.nickName"
                  :value="item.nickName"
                ></el-option>
              </el-select>-->
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="日期" prop="a51">
              <el-date-picker
                :editable="false"
                clearable
                v-model="form.a51"
                type="month"
                value-format="yyyy-MM"
                placeholder="选择日期"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col> -->
          <!--<el-col :span="12">
            <el-form-item label="基地" prop="a52">
              <el-select v-model="form.a52" clearable size="small">
                <el-option
                  v-for="dict in deptOptions"
                  :key="dict.deptId"
                  :label="dict.name"
                  :value="dict.deptId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>-->
          <!-- <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input
                v-model="form.remark"
                placeholder="请输入备注"
                :disabled="openDisabled"
              />
            </el-form-item>
          </el-col> -->
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listProductionmetermonth,
  getProductionmetermonth,
  delProductionmetermonth,
  addProductionmetermonth,
  updateProductionmetermonth,
  getDate,
} from "@/api/report/process/productionmetermonth";
import { getSelectList } from "@/api/basic/workshop/workshop";
import { getInfo } from "@/api/login";
import { listUser } from "@/api/system/user";
export default {
  name: "Productionmetermonth",
  data() {
    return {
      /* 当前用户名 */
      nickName: "",
      userList: [],
      //弹窗是否禁止编辑
      openDisabled: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产基地用电记录表格数据
      productionmetermonthList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        a2: null,
        a3: null,
        a4: null,
        a5: null,
        a6: null,
        a7: null,
        a8: null,
        a9: null,
        a10: null,
        a11: null,
        a12: null,
        a13: null,
        a14: null,
        a15: null,
        a16: null,
        a17: null,
        a18: null,
        a19: null,
        a20: null,
        a21: null,
        a22: null,
        a23: null,
        a24: null,
        a25: null,
        a26: null,
        a27: null,
        a28: null,
        a29: null,
        a30: null,
        a31: null,
        a32: null,
        a33: null,
        a34: null,
        a39: null,
        a35: null,
        a36: null,
        a37: null,
        a38: null,
        a40: null,
        a41: null,
        a42: null,
        a43: null,
        a44: null,
        a45: null,
        a46: null,
        a47: null,
        a48: null,
        a49: null,
        a50: null,
        a51: null,
        a511: null,
        a52: null,
      },
      // 部门树选项
      deptOptions: undefined,
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
    this.queryUserList();
    this.getDeptTreeselect();
  },
  methods: {
    /** 查询部门下拉树结构 */
    getDeptTreeselect() {
      getSelectList().then((response) => {
        this.deptOptions = response.data;
      });
    },
    // 获取时间范围的数据
    handleDate() {
      // 判断时间
      if (this.form.a51 == null || this.form.a511 == null) {
        this.msgError("请输入日期");
      } else {
        getDate({
          a51: this.form.a51 + " 00:00:00",
          a511: this.form.a511 + " 23:59:59",
        }).then((res) => {
          // console.log(res)
          let obj = res.data;
          this.form.a3 = obj.a3;
          this.form.a4 = obj.a4;
          this.form.a5 = obj.a5;
          this.form.a6 = obj.a6;
          this.form.a7 = obj.a7;
          this.form.a8 = obj.a8;
          this.form.a9 = obj.a9;
          this.form.a10 = obj.a10;
          this.form.a11 = obj.a11;
          this.form.a12 = obj.a12;
          this.form.a13 = obj.a13;
          this.form.a14 = obj.a14;
          this.form.a15 = obj.a15;
          this.form.a16 = obj.a16;
          this.form.a17 = obj.a17;
          this.form.a18 = obj.a18;
          this.form.a19 = obj.a19;
          this.form.a20 = obj.a20;
          this.form.a21 = obj.a21;
          this.form.a22 = obj.a22;
          this.form.a23 = obj.a23;
          this.form.a24 = obj.a24;
          this.form.a25 = obj.a25;
          this.form.a26 = obj.a26;
          this.form.a27 = obj.a27;
          this.form.a28 = obj.a28;
          this.form.a29 = obj.a29;
          this.form.a30 = obj.a30;
          this.form.a31 = obj.a31;
          this.form.a32 = obj.a32;
          this.form.a33 = obj.a33;
          this.form.a34 = obj.a34;
          this.form.a39 = obj.a39;
          this.form.a35 = obj.a35;
          this.form.a36 = obj.a36;
          this.form.a37 = obj.a37;
          this.form.a38 = obj.a38;
          this.form.a40 = obj.a40;
          this.form.a41 = obj.a41;
          this.form.a42 = obj.a42;
          this.form.a43 = obj.a43;
          this.form.a44 = obj.a44;
          this.form.a45 = obj.a45;
          this.form.a46 = obj.a46;
        });
      }
    },
    // 生产合计
    productionTotal() {
      let sum = 0;
      for (let i = 8; i <= 34; i += 2) {
        //排除 1.提升机 2.净化系统
        if (i == 22 || i == 26) {
          continue;
        }
        sum += parseInt(this.form["a" + i] == null ? 0 : this.form["a" + i]);
      }
      this.form.a39 = sum;
    },
    //生活合计
    liveTotal() {
      this.form.a44 =
        //增加  1.提升机 2.净化系统
        parseFloat(this.form.a22 == null ? 0 : this.form.a22) +
        parseFloat(this.form.a26 == null ? 0 : this.form.a26) +
        parseInt(this.form.a36 == null ? 0 : this.form.a36) +
        parseInt(this.form.a38 == null ? 0 : this.form.a38) +
        parseInt(this.form.a41 == null ? 0 : this.form.a41) +
        parseInt(this.form.a43 == null ? 0 : this.form.a43);
    },
    /** 查询生产基地用电记录列表 */
    getList() {
      this.loading = true;
      listProductionmetermonth(this.queryParams).then((response) => {
        this.productionmetermonthList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        a2: "LK-QG-LS1-04-000-11-01",
        a3: null,
        a4: null,
        a5: null,
        a6: null,
        a7: null,
        a8: null,
        a9: null,
        a10: null,
        a11: null,
        a12: null,
        a13: null,
        a14: null,
        a15: null,
        a16: null,
        a17: null,
        a18: null,
        a19: null,
        a20: null,
        a21: null,
        a22: null,
        a23: null,
        a24: null,
        a25: null,
        a26: null,
        a27: null,
        a28: null,
        a29: null,
        a30: null,
        a31: null,
        a32: null,
        a33: null,
        a34: null,
        a39: null,
        a35: null,
        a36: null,
        a37: null,
        a38: null,
        a40: null,
        a41: null,
        a42: null,
        a43: null,
        a44: null,
        a45: null,
        a46: null,
        a47: null,
        a48: null,
        a49: null,
        a50: this.nickName,
        a51: null,
        a511: null,
        a52: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
        remark: null,
      };
      this.resetForm("form");

      // const myDate = new Date();
      // const year = myDate.getFullYear();
      // const month = myDate.getMonth() + 1;
      // this.form.a51 = `${year}-${month}`;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.form.a52 = 101;
      this.openDisabled = false;
      this.open = true;
      this.title = "添加生产基地用电记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.openDisabled = false;
      const id = row.id || this.ids;
      getProductionmetermonth(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改生产基地用电记录";
      });
    },
    /** 查看按钮 */
    handleView(row) {
      this.reset();
      this.openDisabled = true;
      const id = row.id || this.ids;
      getProductionmetermonth(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "查看生产基地用电记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateProductionmetermonth(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addProductionmetermonth(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除生产基地用电记录编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delProductionmetermonth(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "productionmetermonth/productionmetermonth/export",
        {
          ...this.queryParams,
        },
        "生产基地用电记录" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    excelhandleView(row) {
      this.download(
        "Laboratory/productionmetermonth/exportexcel?id=" + row.id,
        {
          ...this.queryParams,
        },
        "每月用电记录表" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    //接收编号
    nameChange(e) {
      this.form.a2 = e;
    },
    /* 查询用户列表 */
    queryUserList() {
      listUser().then((response) => {
        this.userList = response.rows;
      });
      getInfo().then((response) => {
        this.nickName = response.user.nickName;
      });
    },
  },
};
</script>
